Subject: AMAPI: a highly-biased account
From: [email-masked] (robert hood)
To: Multiple recipients of list <[email-masked]>
Date: Thu, 14 Dec 1995 01:47:05 -0500

I saw the post about this new 3D Modeler, and decided to check it out.
Aside from the hails over the unique interface, I noticed that it had
a scripting system.  So, you know me, I had to check it out...

ARRGGGHHH!  It's Tcl!  Run for your lives!  =|^)

Here's one of the simpler scripts, 'cylinder.tcl', that creates a cylinder
using AMAPI:

-------------------------------------------------------------------------
#SPEC -realname ''make a cylinder''

set res [getvalue -type1 ''int'' -name1 ''nb tranches'' -value1 10 -type2 ''world'' -name2 ''hauteur'' -value2 5 -type3 ''world'' -name3 ''rayon'' -value3 4]
if {$res == ""} return

set nbslices [.match $res result1 -int]
set high [.match $res result2 -world]
set radiu [.match $res result3 -world]

set oldplane [.amapi plane]
.amapi setplane -viewup
set circ [.match [circle -radius [.world2unit $radiu] -numpts 8 -orig {0 0 0}] shape -shape]
if {$circ == ""} return
newshape mycircle $circ

.amapi setplane -viewfront
set pt1 [lindex [mycircle -points] 0]
set pt2 [list [lindex $pt1 0] [expr [lindex $pt1 1] + $high] [lindex $pt1 2]]

newshape myprofil {
	addpoint $pt1
	addpoint $pt2
}
myprofil -status open 
myprofil -checkin

set prof [myprofil -ref]
set profil [smooth -shape $prof -range $nbslices]

extrude -curve1 $circ -curve2 $profil -close
set newplane [.match $oldplane plane -string]
.amapi setplane $newplane
-------------------------------------------------------------------------

Since I cannot quite figure out what is going on in this script (and
don't want to take the time to), I did a BML script to create a
user-defined cylinder, complete with a user interface:

-------------------------------------------------------------------------
main
{
    var rad,top,bottom,axis,sides;
    var items[3];

    rad = <1.0,1.0,1.0>;
    top = 1.0;
    bottom = 0.0;
    axis = 2;       // Y
    sides = 16;

    reqbegin("Cylinder");

    var c1 = addcontrol(rad,"Radius");
    var c2 = addcontrol(top,"Top");
    var c3 = addcontrol(bottom,"Bottom");
    items[1] = "X"; items[2] = "Y"; items[3] = "Z";
    var c4 = addcontrol(axis,"Axis",items);
    var c5 = addcontrol(sides,"Sides");

    if(reqpost())
    {
        rad = getvalue(c1);
        top = getvalue(c2);
        bottom = getvalue(c3);
        axis = getvalue(c4);
        sides = getvalue(c5);
    }
    else
        return;

    makedisc(rad,top,bottom,items[axis],sides);
}
-------------------------------------------------------------------------

I don't know about you, but, better interface or not, I'd really rather
use BML.  =|^)

Render me gone,               |||
Bob                         ^(===)^
-------------------------oOO--(_)--OOo--------------------------------------
Bob Hood            | All governments suffer from a recurring problem:
Virtual Visions Inc.| Power attracts pathological personalities.  It is not
1.303.989.4191      | that power corrupts, but that it is magnetic to the
                    | corruptible.  Such people have a tendency to become
[email-masked]    | drunk on violence, a condition to which they are
[email-masked]      | quickly addicted              - Frank Herbert
----------------------------------------------------------------------------